package com.example.fsd.service.comments;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.fsd.common.result.R;
import com.example.fsd.pojo.Comments;
import com.example.fsd.mapper.CommentsMapper;
import com.example.fsd.pojo.Jdal;
import com.example.fsd.service.comments.ICommentsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.fsd.vo.PageVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhangguihong
 * @since 2024-11-19
 */
@Service
public class CommentsServiceImpl extends ServiceImpl<CommentsMapper, Comments> implements ICommentsService {

    @Override
    public R saveComments(Comments comments) {
        return R.ok().put("flag",this.save(comments));
    }

    @Override
    public R getCommentsList(PageVo pageVo) {
        //查询所有分页评论
        LambdaQueryWrapper<Comments> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        Page<Comments> page = new Page<>(pageVo.getPageNo(), pageVo.getPageSize());
        IPage<Comments> CommentsIPage = this.page(page, lambdaQueryWrapper);
        return R.ok().put("CommentsIPage", CommentsIPage);
    }

}
